#include<bits/stdc++.h>
using namespace std;
vector<int>v[250];
int n , m;
bool vis[250];
void dfs(int x){
	cout << x << " ";
	vis[x] = 1;
	int len = v[x].size();
	for(int i = 0 ; i < len ; i++){
		if(!vis[v[x][i]]){
			dfs(v[x][i]);
		}
	}
}
int main(){
	cin >> n >> m;
	while(m--){
		int a , b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1);
	return 0;
}
